﻿// ====================================
// Created By Angie.D 2010.6
// ====================================

using System;
using System.Collections.Generic;
using System.Text;

using System.Reflection;

namespace WOWMultiPlay
{
    public static class Common
    {
        public static string GetVKName(int value)
        {
            Assembly Asm = Assembly.GetExecutingAssembly();
            Type TypeWin32API = Asm.GetType("WOWMultiPlay.WindowsAPI");
            Type TypeVK = TypeWin32API.GetNestedType("VirtualKey");

            FieldInfo[] FIs = TypeVK.GetFields();
            foreach (FieldInfo FI in FIs)
            {
                if ((int)FI.GetValue(null) == value)
                    return FI.Name;
            }

            return string.Empty;
        }

        public static int GetVKValue(string name)
        {
            Assembly Asm = Assembly.GetExecutingAssembly();
            Type TypeWin32API = Asm.GetType("WOWMultiPlay.WindowsAPI");
            Type TypeVK = TypeWin32API.GetNestedType("VirtualKey");

            FieldInfo[] FIs = TypeVK.GetFields();
            foreach (FieldInfo FI in FIs)
            {
                if (FI.Name == name)
                    return (int)FI.GetValue(null);
            }

            return 0;
        }

        public static string GetMODName(int value)
        {
            Assembly Asm = Assembly.GetExecutingAssembly();
            Type TypeWin32API = Asm.GetType("WOWMultiPlay.WindowsAPI");
            Type TypeVK = TypeWin32API.GetNestedType("MOD");

            FieldInfo[] FIs = TypeVK.GetFields();
            foreach (FieldInfo FI in FIs)
            {
                if ((int)FI.GetValue(null) == value)
                    return FI.Name;
            }

            return string.Empty;
        }
    }
}